home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / s_to_z / uimagine / image.pas < prev    next >
Pascal/Delphi Source File  |  1996-09-15  |  2KB  |  69 lines

  1. {****************************************************************************}
  2. { This unit allows for an easy interface with the imagine.dll                }
  3. {****************************************************************************}
  4.  
  5. unit Image;
  6.  
  7.  
  8. interface
  9.  
  10.  
  11. uses
  12.   WinTypes, WinProcs, SysUtils;
  13.  
  14. type
  15.   TFPintCB = Procedure( i: Integer );
  16.   function ConvertImage(aCallback: TFPintCB; nDither: Integer;
  17.     sIn, sOut: String): Integer;
  18.   function ReturnError(Err: Integer): String;
  19.   function ConvertToBMP(aCallback: TFPintCB; nDither: Integer;
  20.     FileIn, FileOut: PChar): Integer;
  21.  
  22.  
  23. implementation
  24.  
  25.  
  26. function ConvertToBMP; external 'IMAGINE' index 1;
  27.  
  28.  
  29. {****************************************************************************}
  30. function ConvertImage(aCallback: TFPintCB; nDither: Integer;
  31.   sIn, sOut: String): Integer;
  32. {****************************************************************************}
  33. var
  34.   FileIn: array[0..144] of Char;
  35.   FileOut: array[0..144] of Char;
  36.   iDither: Integer;
  37. begin
  38.   StrPCopy(FileIn, sIn);
  39.   StrPCopy(FileOut, sOut);
  40.   Result := ConvertToBMP(aCallback, nDither, FileIn, FileOut);
  41. end;
  42.  
  43.  
  44. {****************************************************************************}
  45. function ReturnError(Err: Integer): String;
  46. {****************************************************************************}
  47. var
  48.   ErrString: String;
  49. begin
  50.   case Err of
  51.     1:  Result := 'Unsupported file feature.';
  52.     2:  Result := 'Input file read error.';
  53.     3:  Result := 'Insufficient memory.';
  54.     4:  Result := 'Bad palette.';
  55.     5:  Result := 'Color reduction error.';
  56.     6:  Result := 'Invalid file structure.';
  57.     7:  Result := 'Output file write error - out of disk space?';
  58.     8:  Result := 'Temporary file error - out of disk space?';
  59.     9:  Result := 'Could not open input file.';
  60.     10: Result := 'Could not create output file.';
  61.     11: Result := 'Can''t dither bitmap.';
  62.   else
  63.     Result := 'Unknown processing error';
  64.   end;
  65. end;
  66.  
  67.  
  68. end.
  69.